import { Component, ComponentData } from "maishu-jueying";
import { SpinerComponent } from "controls/spiner-component";
import { PageProps } from "maishu-chitu-react";
import { LocalService } from "mobile/services/localService";
import { loadComponents } from "mobile/site";
import { pageDatas } from "services/page-datas";

interface State {
    status?: "loading" | "complete",
    pageData: ComponentData
}
interface Props extends PageProps {
    data: {
        name: string,
        id: string
    }
}
export default class ShoppingCartPage extends SpinerComponent<Props, State> {
    localSevice: LocalService;
    constructor(props: Props) {
        super(props);

        this.localSevice = this.props.createService(LocalService);
    }
    async loadData(): Promise<Partial<State>> {
        let record = await pageDatas.shoppingCart();
        await loadComponents(record.pageData);
        return { pageData: record.pageData };
    }
    render() {
        console.assert(this.state != null);
        let { pageData } = this.state;
        return Component.createElement(pageData)
    }
}